const xlsx = require("node-xlsx");
const fs = require("fs");
//保存当前id图书信息
function readXlsx() {
  console.log("读取xlx");
  let dataArr = xlsx.parse("./data/UKALL.xlsx");
  let xlsxData = dataArr[0].data;
  console.log("写入");
  let txtArr = [];
  xlsxData.forEach((value) => {
    if (value.length > 0) {
      txtArr.push(value[0]);
    }
  });
  console.log(txtArr.length);
  txtArr = unique(txtArr);
  console.log(txtArr.length);
  txtArr.forEach((value) => {
      fs.appendFileSync("./data/UKAsin1.txt", value + "\n", "utf8");
  });
  console.log("结束");

}
function unique(arr) {
  let res = [];
  let json = {};
  for (let i = 0; i < arr.length; i++) {
    if (!json[arr[i]]) {
      res.push(arr[i]);
      json[arr[i]] = 1;
    }
  }
  return res;
}
readXlsx();
